﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DBLayer
{
    public partial class Sale
    {
        public decimal IVA
        {
            get
            {
                return Decimal.Subtract(Total, SubTotal);
            }
        }
        public decimal SubTotal
        {
            get
            {
                return Decimal.Divide(Total, iva);
            }
        }
        public decimal Total
        {
            get
            {
                return Decimal.Subtract(total,TotalDiscount);
            }
        }

        public decimal TotalDollar
        {
            get
            {
                if (RateExchange > 0)
                    return Decimal.Divide(Total, (decimal)RateExchange);
                else
                    return 0;
            }
        }
        public decimal TotalDiscount
        {
            get
            {
                return Decimal.Multiply(total, PercentageDiscount);
            }
        }

        public decimal PercentageDiscount
        {
            get 
            {
                if (Discount != null)
                    return Decimal.Divide((decimal)Discount.Percentage,(decimal)100);   
                else
                    return 0;
            }
        }
        public string CookingNote { get; set; }
        public string OrderToAdress { get; set; }
        public bool RePrintTicket { get; set; }
        public string OrderPhone { get; set; }
        
        private decimal total
        {
            get
            {
                return SaleDetail.Sum(h => Decimal.Multiply((decimal)h.Cuantity, (decimal)h.UnitPrice));
            }
        }
        private decimal iva
        {
            get 
            {
                decimal iva = 1;
                return iva += Decimal.Divide((decimal)PercentageTax, (decimal)100);
            }
        }
    }
}
